




/**
 * 位标志相等测试
 */
export enum BitFlagEqualTestType {
    /**
     * 相等:A === B
     */
    equal = "equal", // "相等"
    /**
     * 相交:A & B
     */
    intersect = "intersect", // "相交"
    /**
     * 交等:A & B === A
     */
    intersectEqual = "intersectEqual", // "交等"
}


export namespace BitFlagEqualTestType {
    /**
     * 获取 位标志相等测试的函数
     * @param testType 默认 intersectEqual
     * @returns 
     */
    export function getEqualFun(testType?:BitFlagEqualTestType|null){
        let equal:(a:number,b:number)=>number|boolean;
        switch(testType){
            case BitFlagEqualTestType.equal:
                equal = ((a,b)=> (a === b));
            case BitFlagEqualTestType.intersect:
                equal = ((a,b)=> (a & b));
            default:
                equal = ((a,b)=> ((a & b) === a));
        }

        return equal;
    }
}